package it.azienda.managerworkstandard.view;

import it.azienda.framework.persistenza.DAOConnectionSingleton;
import it.azienda.framework.utilita.Utilita;
import it.azienda.framework.view.Dettaglio;
import it.azienda.managerworkstandard.modello.BeanLogin;
import it.azienda.managerworkstandard.modello.BeanPrimaNotaDb;
import java.util.ArrayList;
import javax.faces.component.html.HtmlForm;
import javax.faces.context.FacesContext;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;

public class DettaglioPrimaNotaDb extends Dettaglio{
    
    private HtmlForm form = new HtmlForm();
    private BeanPrimaNotaDb beanPrimaNotaDb;
    
    public void setBeanPrimaNotaDb(BeanPrimaNotaDb beanPrimaNotaDb) {
        setObj(beanPrimaNotaDb);
        this.beanPrimaNotaDb = beanPrimaNotaDb;
    }
    
    public BeanPrimaNotaDb getBeanPrimaNotaDb(){
        return (BeanPrimaNotaDb)getObj();
    }
    
    public HtmlForm getForm() {
        form = (HtmlForm) Utilita.getSession().getAttribute("form");
        if (form == null) {
            form = new HtmlForm();
        }
        Utilita.getSession().removeAttribute("form");
        return form;
    }
    
    public void setForm(HtmlForm form) {
        setFormObject(form);
        this.form = form;
        Utilita.getSession().setAttribute("form",form);
    }
    
    public boolean controlliPrimaSalvataggio() {
        FacesContext ctx = FacesContext.getCurrentInstance();
        beanPrimaNotaDb =(BeanPrimaNotaDb) ctx.getExternalContext().getRequestMap().get("beanPrimaNotaDb");
        BeanLogin login = (BeanLogin) Utilita.getSession().getAttribute("login");
        beanPrimaNotaDb.setAnno(login.getAnnoGestione());
        return false;
    }
}
